/*     */ package com.zimbra.cs.zimlet;
/*     */ 
/*     */ import com.zimbra.common.soap.Element;
/*     */ import java.io.File;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class ZimletDescription
/*     */   extends ZimletMeta
/*     */ {
/*     */   public static final String ZIMLET_REGEX_EXTENSION_CLASS = "com.zimbra.cs.zimlet.handler.RegexHandler";
/*     */   private List<String> mScripts;
/*     */   private List<String> mStyleSheets;
/*     */   private String mContentObject;
/*     */   private String mPanelItem;
/*     */   private String mExtensionClass;
/*     */   private String mKeyword;
/*     */   private String mRegexString;
/*     */   private List<String> mTargets;
/*     */   private String mDisableUIUndeploy;
/*     */   
/*     */   public ZimletDescription(File desc)
/*     */     throws ZimletException
/*     */   {
/*  46 */     super(desc);
/*     */   }
/*     */   
/*     */   public ZimletDescription(String desc) throws ZimletException {
/*  50 */     super(desc);
/*     */   }
/*     */   
/*     */   protected void initialize() {
/*  54 */     this.mScripts = new ArrayList();
/*  55 */     this.mStyleSheets = new ArrayList();
/*  56 */     this.mTargets = new ArrayList();
/*     */   }
/*     */   
/*     */   protected void validateElement(Element elem) throws ZimletException {
/*  60 */     if (elem.getName().equals("contentObject")) {
/*  61 */       this.mContentObject = elem.toString();
/*  62 */     } else if (elem.getName().equals("zimletPanelItem")) {
/*  63 */       this.mPanelItem = elem.toString();
/*  64 */     } else if (elem.getName().equals("serverExtension")) {
/*  65 */       parseServerExtension(elem);
/*  66 */     } else if (elem.getName().equals("include")) {
/*  67 */       parseResource(elem);
/*  68 */     } else if (elem.getName().equals("includeCSS")) {
/*  69 */       parseCss(elem);
/*  70 */     } else if (elem.getName().equals("target")) {
/*  71 */       this.mTargets.add(elem.getText());
/*  72 */     } else if (elem.getName().equals("disableUIUndeploy")) {
/*  73 */       this.mDisableUIUndeploy = elem.getText();
/*     */     }
/*     */   }
/*     */   
/*     */   private void parseResource(Element resource) throws ZimletException {
/*  78 */     this.mScripts.add(resource.getText());
/*     */   }
/*     */   
/*     */   private void parseCss(Element css) throws ZimletException {
/*  82 */     this.mStyleSheets.add(css.getText());
/*     */   }
/*     */   
/*     */   private void parseServerExtension(Element serverExt) throws ZimletException {
/*  86 */     assert (serverExt.getName().equals("serverExtension"));
/*  87 */     String val = serverExt.getAttribute("hasKeyword", "");
/*  88 */     if (val.length() > 0) {
/*  89 */       this.mKeyword = val;
/*     */     }
/*  91 */     val = serverExt.getAttribute("extensionClass", "");
/*  92 */     if (val.length() > 0) {
/*  93 */       this.mExtensionClass = val;
/*     */     }
/*  95 */     val = serverExt.getAttribute("regex", "");
/*  96 */     if (val.length() > 0) {
/*  97 */       this.mExtensionClass = "com.zimbra.cs.zimlet.handler.RegexHandler";
/*  98 */       this.mRegexString = val;
/*     */     }
/*     */   }
/*     */   
/*     */   public String getContentObjectAsXML() {
/* 103 */     assert (this.mTopElement != null);
/* 104 */     return this.mContentObject;
/*     */   }
/*     */   
/*     */   public String getPanelItemAsXML() {
/* 108 */     assert (this.mTopElement != null);
/* 109 */     return this.mPanelItem;
/*     */   }
/*     */   
/*     */   public String getContentObjectAsJSON() {
/* 113 */     assert (this.mTopElement != null);
/* 114 */     return null;
/*     */   }
/*     */   
/*     */   public String getPanelItemAsJSON() {
/* 118 */     assert (this.mTopElement != null);
/* 119 */     return null;
/*     */   }
/*     */   
/*     */   public String[] getScripts() {
/* 123 */     if (this.mScripts.isEmpty()) {
/* 124 */       return new String[0];
/*     */     }
/* 126 */     return (String[])this.mScripts.toArray(new String[0]);
/*     */   }
/*     */   
/*     */   public String[] getStyleSheets() {
/* 130 */     if (this.mStyleSheets.isEmpty()) {
/* 131 */       return new String[0];
/*     */     }
/* 133 */     return (String[])this.mStyleSheets.toArray(new String[0]);
/*     */   }
/*     */   
/*     */   public String getServerExtensionClass() {
/* 137 */     return this.mExtensionClass;
/*     */   }
/*     */   
/*     */   public String getServerExtensionKeyword() {
/* 141 */     return this.mKeyword;
/*     */   }
/*     */   
/*     */   public boolean getServerExtensionHasKeyword() {
/* 145 */     return this.mKeyword != null;
/*     */   }
/*     */   
/*     */   public String getRegexString() {
/* 149 */     return this.mRegexString;
/*     */   }
/*     */   
/*     */   public boolean checkTarget(String target) {
/* 153 */     return this.mTargets.contains(target);
/*     */   }
/*     */   
/*     */   public List<String> getTargets() {
/* 157 */     return this.mTargets;
/*     */   }
/*     */   
/*     */   public String getDisableUIUndeploy() {
/* 161 */     return this.mDisableUIUndeploy;
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/zimlet/ZimletDescription.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */